Version 3.0
User's Guide

Using Negative Comparisons

Previous | Next
Contents

As you've seen, you can show and hide portions of your pages based on a wide range of variables within NetCloak. This gives you a great deal of flexibility and you can create fairly complex conditions in which each part of a page will be visible. You can also negate the comparison in conditional SHOW and HIDE commands which allows you to show or hide in all cases except when the condition is true.

For example, assume you wanted to have a portion of your page visible during the normal business week, Monday through Friday. You could write:

    <HIDE>    <SHOW_DAY BEGINS MON TUE WED THU FRI>    This text is visible during the week only.

But there is another way to make this same statement. Instead of saying "show text on Monday, Tuesday, Wednesday, Thursday, and Friday" (as we did above), you could say "show text on all days except Saturday and Sunday". To do this, you would use:

    <HIDE><SHOW_DAY# BEGINS SAT SUN>    This text is visible during the week only.

To be honest, this isn't really much easier, at least in this example. But what if you wanted to show text based on SHOW_DOMAIN to all users except those at a certain address. You certainly wouldn't want to list every domain on the Internet, so <SHOW_DOMAIN# 192.1.2.3> could be very handy when you want to show a section of your page to everyone except "192.1.2.3".

Of course, you could, in many cases, also use the HIDE commands instead. For example, the "192.1.2.3" example could have been written as:

    <SHOW><HIDE_DOMAIN 192.1.2.3>

The real power of negating comparisons to make "except" statements comes into play when combining commands.

Combining Commands by Negating

When building more complicated conditionals, using "HIDE" in place of "SHOW except" is no longer an option. Remember that SHOW and HIDE are fundamentally different in that SHOW will never "hide" text, and HIDE will never cause text to be seen. So, if we wanted to have a portion of text visible only to "JOE" from domain "192.1.", we could not use:

    <HIDE><SHOW_USERNAME IS JOE>    <SHOW_DOMAIN BEGINS 192.1.>    This text would be visible to "JOE" AND to users coming from "192.1"!

In this case, as long as the user's name was Joe, it wouldn't matter what their domain was, because the <SHOW_DOMAIN 192.1.> command would never turn the "faucet" off. Joe's all over the Internet would have access to the text. Similarly, anyone in the domain 192.1 would also see the text, no matter what their name.

In general, any time you have two conditions that both need to be met, you will encounter this problem. Two SHOW commands following each other always have an AND logic. All is not lost, though. By changing the second command from SHOW to HIDE and negating the comparison ("hide except") you can create a logical OR instead of AND. This technique is sometimes called the "except variation" because the sense of the command becomes "hide except when (comparison)".

In the example above, you could use the except variation to achieve the desired effect:

    <HIDE><SHOW_USERNAME IS JOE>    <HIDE_DOMAIN# BEGINS 192.1.>    This is what we wanted!  Only Joe can see this, and only if he's at 192.1.

The first part of this is simple enough... Hide text, then let "Joe" see it again. The command <HIDE_DOMAIN# BEGINS 192.1.> (note the "#" character) is really saying "OK, text is on, so it's Joe. Now hide the text except when he is in the '192.1' domain".

To combine the effect of two commands to hide the HTML on Saturday between 8:00 and 9:00, change from SHOW to HIDE and negate the comparison in the second command:

    <SHOW>    <HIDE_DAY BEGINS SAT>    <SHOW_TIME# BEGINS 08>

The HIDE_DAY command will hide the HTML all day on Saturday, but the SHOW_TIME# ("show_time except") command will cancel out the effect of the HIDE_DAY except between 8:00 and 9:00. This results is the HTML being hidden only on Saturday between 8:00 and 9:00.

Another common use for this technique is with username and password commands. These commands each work on the username or password, but not both. To show based on the username and password, use:

    <HIDE><SHOW_USERNAME IS clarus>    <HIDE_PASSWORD# IS moof>

The SHOW_USERNAME will only show HTML following it if the username is "clarus", and the HIDE_PASSWORD# will hide it again except when the password is also "moof". This results in the HTML following the show/hide-except commands being shown only when the username and password are both correct.

You've no doubt noticed by now that there is usually more than one way to achieve the same result, by converting SHOWs to HIDEs and then negating the comparison operator, or by using an "except" variation of a command, or by using a different operator. For instance, a "LT" operator is identical to a "#GT=" operator. You may use whichever combination of comparison operators and commands you feel most comfortable with that achieves the desired results.


Copyright © 1996-1999 Maxum Development Corporation

http://www.maxum.com/
Previous | Next
Contents